//
//  TZTableViewCell.m
//  一些零碎的知识
//
//  Created by user on 16/3/19.
//  Copyright © 2016年 Burning. All rights reserved.
//

#import "TZTableViewCell.h"
#import "TZRowModel.h"
#import "TZRowPushModel.h"
#import "TZSwitchModel.h"

@implementation TZTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"cell";
    
    TZTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (cell == nil) {
        cell = [[TZTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }
    return cell;
    
    
    
    
}

- (void)setModel:(TZRowModel *)model{
    
    _model = model;
    
    self.textLabel.text = model.name;
    self.imageView.image = [UIImage imageNamed:model.icon];
    
    [self setAccessoryType];
}

- (void)setAccessoryType{
    
    if ([self.model isKindOfClass:[TZRowPushModel class]]) {
        
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }else if ([self.model isKindOfClass:[TZSwitchModel class]]){
        self.accessoryView = [UISwitch new];
    }else{
        self.accessoryType = UITableViewCellStyleDefault;
    }
    
    
}

@end
